#include "sys.h"
#include "delay.h"
#include "usart.h"
#include  "stdlib.h"
#include "includes.h"

#define RGB888_RED      0x00ff0000  
#define RGB888_GREEN    0x0000ff00  
#define RGB888_BLUE     0x000000ff 


//***********TFTLCD****************************//

#define CS_SET GPIO_SetBits(GPIOC,GPIO_Pin_9)
#define CS_CLR GPIO_ResetBits(GPIOC,GPIO_Pin_9)

#define RS_SET GPIO_SetBits(GPIOC,GPIO_Pin_8)
#define RS_CLR GPIO_ResetBits(GPIOC,GPIO_Pin_8)

#define WR_SET GPIO_SetBits(GPIOC,GPIO_Pin_7)
#define WR_CLR GPIO_ResetBits(GPIOC,GPIO_Pin_7)

#define RD_SET GPIO_SetBits(GPIOC,GPIO_Pin_6)
#define RD_CLR GPIO_ResetBits(GPIOC,GPIO_Pin_6)


#define C1 0x551A00
#define C2 0xdeaa7a
#define C3 0xc48c52
#define C4 0xb57f4e
#define C5 0xffffff
#define C6 0xff6464
#define C7 0xe52b2b
#define C8 0xefefef
#define C9 0xa06938
#define C10 0xdea876

#define c1 0x551A00
#define c2 0xdeaa7a
#define c3 0xc48c52
#define c4 0xb57f4e
#define c5 0xffffff
#define c6 0xff6464
#define c7 0xe52b2b
#define c8 0xefefef
#define c9 0xa06938
#define c10 0xdea876

//#define SDA_IN()  {GPIOC->CRH&=0XFFFF0FFF;GPIOC->CRH|=8<<12;}
//#define SDA_OUT() {GPIOC->CRH&=0XFFFF0FFF;GPIOC->CRH|=3<<12;}


int TFT_init(void);
void TFT_test(void);
void TFT_io_init(void);
void TFT_WRITE(u8 data_reg, int flag);
void TFT_WRITE_16(u16 data, int flag);
int draw_point(u16 a, u16 b, u16 color);
int draw_point_one(u16 a, u16 b, u16 color);
void TFT_clear(u16 color);
void TFT_clear_num_1(void);
void TFT_clear_num_2(void);
void TFT_background(u16 color);
char number_tran_to_display_ge(int cnt);
char number_tran_to_display_shi(int cnt);
char number_tran_to_display_bai(int cnt);
char number_tran_to_display_qian(int cnt);
char number_tran_to_display_wan(int cnt);

char number_tran_to_display_one(int cnt);
char number_tran_to_display_two(int cnt);
char number_tran_to_display_three(int cnt);
char number_tran_to_display_four(int cnt);
char number_tran_to_display_five(int cnt);
char number_tran_to_display_six(int cnt);
char number_tran_to_display_seven(int cnt);
char number_tran_to_display_eight(int cnt);

u16 RGB888ToRGB565(unsigned int n888Color ,int flag);
void draw_word(int x, int y, char word, u16 color);
void draw_number(int x, int y, char number, u16 color);
void draw_across(int x, int y, u16 color);
void draw_vertical(int x, int y, u16 color);
void draw_vertical_short(int x, int y, u16 color);
void num_for_test(float x, float y, float z, int a, int b, int c);
void num_one_for_test(int a);
void num_16_for_test(int x, int y, int z, int a, int b, int c);
void num_for_dmp(float x, float y, float z,short int a,short int b,short int c,short int d);



